<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/common/meta.jsp"></jsp:include>
<jsp:include page="/common/css_js.jsp"></jsp:include>
<script>
	$(document)
			.ready(
					function() {
						//聚焦第一个输入框
						$("#name").focus();
						//为inputForm注册validate函数
						$("#inputForm").validate({
							rules : {
								name : {
									required : true,
									remote : "role!checkRoleName.action?oldRoleName="+encodeURIComponent('${name}')
								}
							},
							messages : {
								name : {
									required : "角色名不能为空！",
									remote : "角色名已存在"
								}
							}
						});
						$("#authorityTree").treeview({
							persist: "location",
							collapsed: true,
							unique: true
						});
					});
</script>
</head>

<body>
	<s:if test="id == null">
		<jsp:include page="/common/content_top.jsp"><jsp:param name="title" value="新增角色"/></jsp:include>
	</s:if>
	<s:else>
		<jsp:include page="/common/content_top.jsp"><jsp:param name="title" value="修改角色"/></jsp:include>
	</s:else>
	<br/>
	<form id="inputForm" action="role!save.action" method="post">
		<input type="hidden" name="id" value="${id}" />
		<table border="0" style="margin-left: 30px;">
			<tr>
				<td align="right">角色名:</td>
				<td><input type="text" name="name" size="40"
					id="name" value="${name}" />
				</td>
			</tr>			
			
			
			<tr>
				<td align="right">权限:</td>
				<td valign="middle">
					${authrityTree}
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><security:authorize ifAnyGranted="role_update">
						<input class="button" type="submit" value="提交" />&nbsp;
					</security:authorize> <input class="button" type="button" value="返回"
					onclick="history.back()" /></td>
			</tr>
		</table>
	</form>
<jsp:include page="/common/content_bottom.jsp"/>
</body>
</html>
